﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web;
using System.Web.Http.Filters;
using Service.Infrastructure.Implement;
using Service.Infrastructure.Interface;

namespace Web.Filter
{
    public class ApiException : ActionFilterAttribute
    {
        protected readonly ILog ExcptionLogger = new ExceptionLogConfigService();
        /// <summary>
        /// 在调用控制器中的某个方法之后 捕获/处理 异常
        /// </summary>
        /// <param name="aec"></param>
        public override void OnActionExecuted(HttpActionExecutedContext aec)
        {

                if (aec.Exception != null)
                {
                    ExcptionLogger.Logging(aec.Exception, "API");
                    aec.Response = new HttpResponseMessage(HttpStatusCode.InternalServerError);
                }


        }
    }
}